package com.csproj.dispatch.service.dto;


import com.csproj.dispatch.util.DateJsonDeserializer;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.Objects;

/**
 * A DTO for the PositionInfo entity.
 */
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class PositionInfoDTO implements Serializable {

    private String id;

    private String dispatchId;

    private String currentpostion;

    @JsonDeserialize(using = DateJsonDeserializer.class)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8", locale = "zh")
    private ZonedDateTime reportTime;

    @JsonDeserialize(using = DateJsonDeserializer.class)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8", locale = "zh")
    private ZonedDateTime creationTime;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDispatchId() {
        return dispatchId;
    }

    public void setDispatchId(String dispatchId) {
        this.dispatchId = dispatchId;
    }

    public String getCurrentpostion() {
        return currentpostion;
    }

    public void setCurrentpostion(String currentpostion) {
        this.currentpostion = currentpostion;
    }

    public ZonedDateTime getReportTime() {
        return reportTime;
    }

    public void setReportTime(ZonedDateTime reportTime) {
        this.reportTime = reportTime;
    }

    public ZonedDateTime getCreationTime() {
        return creationTime;
    }

    public void setCreationTime(ZonedDateTime creationTime) {
        this.creationTime = creationTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        PositionInfoDTO positionInfoDTO = (PositionInfoDTO) o;
        if(positionInfoDTO.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), positionInfoDTO.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "PositionInfoDTO{" +
            "id=" + getId() +
            ", dispatchId='" + getDispatchId() + "'" +
            ", currentpostion='" + getCurrentpostion() + "'" +
            ", reportTime='" + getReportTime() + "'" +
            ", creationTime='" + getCreationTime() + "'" +
            "}";
    }
}
